<?php
namespace App\Models\WechatMsg;

use App\Models\Project;
use App\Models\UserProject;

class VerifyProject
{
    public  $type;
    public $content;

    public function __construct($type, $content)
    {
        $this->content = $content;
        $this->type = $type;
    }

    public function getOrgWechatConfig()
    {
        $project = Project::where('id', $this->content['project_id'])->first();

        $conf['templateId'] = $project->org->wechat_message_config['project_verify_team'];

        $options = config('wechat');

        $options['app_id'] = $project->org->wechat_app_id;
        $options['secret'] = $project->org->wechat_app_secret;

        $conf['options'] = $options;

        $conf['openId'] = $project->team->user->open_id;

        $conf['url'] = env('ADMIN_URL').'/project/verify?org_id=&status=0';

        return $conf;
    }


    public function getMessageData()
    {

        $project = Project::where('id', $this->content['project_id'])->first();

        $data['first'] = $this->type == 53? "您发起的项目已通过审核":"您发起的项目未通过审核";
        $data['keyword1'] =  "<{$project->name}活动>";
        $data['keyword2'] = $this->type == 53? '已通过':'未通过';
        $data['remark'] = $this->type == 53?'点击查看详情':'';

        return $data;
    }
}